﻿<RadzenTree AllowCheckBoxes="true" @bind-CheckedValues="TreeSelectedValues" Data=@TreeData
            Style="height: 100%;width:100%;overflow: hidden;">
    <RadzenTreeLevel TextProperty="Name" ChildrenProperty="Children" Expanded="@((_)=>true)"
                     HasChildren=@(e => (e as PermissionTreeResponseDto)?.Children?.Any() ?? false) />
</RadzenTree>

@code {

    protected IEnumerable<object> TreeSelectedValues = new List<object>();

    [Parameter]
    public IList<PermissionTreeResponseDto> TreeData { get; set; }

    public void SetDefaultSelected(IEnumerable<object> items)
    {
        TreeSelectedValues = items;
        StateHasChanged();
    }

    public IList<PermissionTreeResponseDto> GetSelected()
    {
        return TreeSelectedValues.Cast<PermissionTreeResponseDto>().ToList();
    }

}
